<template>
  <div class="marketing-config">
    <h3>首页营销</h3>
    <div class="item">
      <span>AI智能助手悬浮窗</span>
      <a-switch v-model:checked="enable" @change="setOrgAiTenantConfigEnable" />
    </div>
  </div>
</template>

<script>
import { getOrgAiTenantConfig, setOrgAiTenantConfigEnable } from '@/api/web/web'
export default {
  name: 'MarketingConfig',
  data() {
    return {
      enable: false
    }
  },
  mounted() {
    this.queryOrgAiTenantConfig()
  },
  methods: {
    async queryOrgAiTenantConfig() {
      const res = await getOrgAiTenantConfig()
      this.enable = !!res.data.enable
    },
    async setOrgAiTenantConfigEnable() {
      await setOrgAiTenantConfigEnable(this.enable ? 1 : 0)
      this.$message.success('设置成功')
    }
  }
}
</script>

<style lang="less" scoped>
.marketing-config {
  background-color: #f7f8fa;
  padding: 20px;
  border-radius: 4px;
  .item {
    margin-top: 24px;
    display: flex;
    align-items: center;
    gap: 10px;
  }
}
</style>
